#!/usr/bin/env bash
SCRIPT_BASE_DIR=$( dirname "${BASH_SOURCE[0]}" )
source "${SCRIPT_BASE_DIR}/cron/abseil_cpp_task.sh"
source "${SCRIPT_BASE_DIR}/cron/caffe_task.sh"
source "${SCRIPT_BASE_DIR}/cron/cmake_task.sh"
source "${SCRIPT_BASE_DIR}/cron/ippicv_task.sh"
source "${SCRIPT_BASE_DIR}/cron/onnxruntime_task.sh"
source "${SCRIPT_BASE_DIR}/cron/onnx_task.sh"
source "${SCRIPT_BASE_DIR}/cron/protobuf_task.sh"
source "${SCRIPT_BASE_DIR}/cron/nsync_task.sh"
source "${SCRIPT_BASE_DIR}/cron/wil_task.sh"

export PATH=${PATH}:${HOME}/bin
export PATH=${PATH}:${HOME}/.local/bin

export PYTHONPATH=${HOME}/caffes/caffe/python:${PYTHONPATH}
export LD_LIBARAY_PATH=${HOME}/caffes/build/lib:${LD_LIBARAY_PATH}

function usage() {
    echo -e "Usage: corn_jobs.sh <action> <log_file>"
    echo -e "\t<action>: function to run"
    echo -e "\t<log_file>: log file"
    exit 1
}

if [ $# -lt 1 ]
then
    usage
fi

logFile="${HOME}/logs/cron_logs.log"
if [ -n "$2" ]
then
    logFile="$2"
fi

# 执行指定的函数
if [ -f "${logFile}" ]
then
    $1 >> "${logFile}" 2>&1
else
    $1 > "${logFile}" 2>&1
fi
